package org.example.helloworld.controller;

import org.example.helloworld.entity.User;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @GetMapping("/user/{id}")
//    PathVariable注解用于获取路径参数
    public String getUserById(@PathVariable int id) {
        System.out.println("id: "+id);
        return "根据id获取用户信息";
    }

    @PostMapping("/user")
    public String save(User user) {
       return "添加用户成功";
    }

    @PutMapping("/user")
    public String update(User user) {
       return "更新用户成功";
    }

    @DeleteMapping("/user/{id}")
    public String deleteById(@PathVariable int id) {
        System.out.println(id);
        return "根据id删除用户";
    }
}
